#include <bits/stdc++.h>
// 2025/01/22
// tag: 
// Author: Zhang Muen
using namespace std;

int soldier[100001];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int l, n;
    cin >> l >> n;
    int mint = 0, maxt = 0;
    for (int i = 1; i <= n; i++){
        cin >> soldier[i];
        mint = max(mint, min(l + 1 - soldier[i], soldier[i]));
        maxt = max(maxt, max(soldier[i], l + 1 - soldier[i]));
    }
    cout << mint << " " << maxt;
    return 0;
}